#ifndef Env_First
#define Env_First
#ifdef __GNUG__
#pragma interface
#endif

#include "Object.h"
#include "Symbol.h"
#include "Rectangle.h"

class OrdCollection;

enum EnvLevel {
	eEnvGlobal,
	eEnvUser,
	eEnvLocal,
	eEnvEnvironment,
	eEnvCommand,
	eEnvChange
};

//---- EnvRec ------------------------------------------------------------------

class EnvRec : public Object {
public:
	Symbol name;
	char *value, *type;
	EnvLevel level;
	bool changed;
	Object *op;
public:
	MetaDef(EnvRec);
	EnvRec(const Symbol &n, const char *v, const char *t, EnvLevel l);
	~EnvRec();
	void ChangeValue(const char *v, const char *t, EnvLevel l);
	void InspectorId(char *buf, int bufSize);
	void Read(Object*);
	void Write(Object*);
	Object *Read2();
	int Compare(Object*);
};

//---- Env ---------------------------------------------------------------------

class Env: public Object {
	static OrdCollection *table;
	static bool terminated;

public:
	MetaDef(Env);
	Env();
	~Env();
	static void Init();
	static const char *getvalue(const char *name);
	static OrdCollection *GetTable()
		{ return table; }
	static bool Defined(const char *name)
		{ return Env::getvalue(name) != 0; }

	static int GetValue(const char *name, int dflt);
	static const char *GetValue(const char *name, const char *dflt);
	static Object *GetValue(const char *name, Object *dflt);
	static Point GetValue(const char *name, const Point &dflt);
	static Rectangle GetValue(const char *name, const Rectangle &dflt);
	static const char *GetPath(const char *name, const char *dflt);

	static void SetValue(const char *name, const char *value,
						EnvLevel level= eEnvChange, const char *type= 0);
	static void SetValue(const char *name, EnvLevel level= eEnvChange);
	static void SetValue(const char *name, int value);
	static void SetValue(const char *name, double value);
	static void SetBoolValue(const char *name, bool value);
	static void Save();
	static EnvRec *Lookup(const char *n);
	static void ReadFile(const char *fname, EnvLevel level);
};

#endif
